<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="utf-8">
    <title>设置流程节点</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" th:href="@{/js/layui/css/layui.css}"  media="all" />
    <link rel="stylesheet" th:href="@{/css/public.css}"  media="all" />
</head>
<body>
<div style="width:100%;-webkit-backface-visibility: hidden;">
    <div class="houselabel">
        <form class="layui-form layui-row" style="padding: 5px 5px;" >
            <div class="layui-row layui-col-space10" style="text-align: center;position: absolute;top: 10px;left: 0px;bottom: 50px;overflow-y: auto;overflow-x: hidden;width: 100%">
                <div class="layui-form-item magt3">
                    <label class="layui-form-label">节点名称:</label>
                    <div class="layui-input-block">
                        <input type="text" name="stepName" lay-verify="required" placeholder="请输入节点名称" autocomplete="off" class="layui-input"
                               required th:value="${speakingFlowStep?.stepName}">
                    </div>
                </div>

                <th:block th:if="${flowId!='null' && 's'.equals(type)}">
                    <div class="layui-form-item magt3">
                        <label class="layui-form-label">跳转到:</label>
                        <div class="layui-input-block">
                            <th:block th:if="${skipTypes}">
                                <select name="skipType" lay-verify="required" lay-filter="skipType" id="skipType" >
                                    <option value="">请选择跳转的流程节点</option>
                                    <option th:each="it:${skipTypes}"  th:value="${it.value}" th:text="${it.desc}"
                                            th:selected="(${it.value} == ${speakingFlowStep?.skipType?.value})"></option>
                                </select>
                            </th:block>
                        </div>
                    </div>
                </th:block>


                <th:block th:if="${flowId!='null' && 'm'.equals(type) }">
                    <div class="layui-form-item magt3">
                        <label class="layui-form-label">跳转到:</label>
                        <div class="layui-input-block">
                            <th:block th:if="${mutiSessionSkipTypes}">
                                <select name="mutiSessionSkipType" lay-verify="required" lay-filter="mutiSessionSkipType" id="mutiSessionSkipType" >
                                    <option value="">请选择跳转的流程节点</option>
                                    <option th:each="it:${mutiSessionSkipTypes}"  th:value="${it.value}" th:text="${it.desc}"
                                            th:selected="(${it.value} == ${speakingFlowStep?.mutiSessionSkipType?.value})"></option>
                                </select>
                            </th:block>
                        </div>
                    </div>
                </th:block>


                <div class="layui-form-item magt3"   style="display: none" id="assignFlowDiv">
                    <label class="layui-form-label">请选择流程:</label>
                    <div class="layui-input-block">
                        <select name="skipFlowId" lay-filter="flows"    >
                            <option value="">请选择流程</option>
                            <option th:each="it:${flows}" th:selected="(${it.id} == ${speakingFlowStep?.skipFlowId})" th:value="${it.id}" th:text="${it.flowName}"></option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item magt3"   style="display: none" id="assignFlowStepDiv">
                    <label class="layui-form-label">请选择流程节点:</label>
                    <div class="layui-input-block">
                        <select name="skipFlowStepId" lay-filter="flows" disabled="true" >
                            <option value="">请选择流程</option>
                            <option th:each="it:${speakingFlowStepList}" th:selected="(${it.id} == ${speakingFlowStep?.skipFlowStepId})" th:value="${it.id}" th:text="${it.stepName}"></option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item magt3">
                    <label class="layui-form-label">提示话术:</label>
                    <div class="layui-input-block">
                        <textarea name="content" placeholder="请输入提示话术" class="layui-textarea" th:text="${speakingFlowStep?.content}"></textarea>
                    </div>
                </div>

                <div class="layui-form-item magt3">
                    <label class="layui-form-label">是否可打断:</label>
                    <div class="layui-input-block" style="text-align: left">
                        <input type="checkbox" name="actionCodeBreak" title="打断话术" th:checked="${speakingFlowStep?.actionCodeBreak==true?'checked':'false'}">
                    </div>
                </div>

                <div class="layui-form-item"  style="display: none" >
                    <input type="text" id="id"  name="id" th:value="${stepId}" value="0" />
                </div>

                <div class="layui-form-item"  style="display: none" >
                    <input type="text" name="type" th:value="${type}"  value="0" />
                </div>

                <div class="layui-form-item"  style="display: none" >
                    <input type="text" name="flowId" th:value="${flowId}" value="0" />
                </div>

                <div class="layui-form-item"  style="display: none" >
                    <input type="text" name="packageId" th:value="${packageId}" value="0" />
                </div>
            </div>
            <div style="position:absolute;left: 0px;bottom: 0px; width: 100%;height: 50px;background-color: #f2f2f2;padding: 0px;display: none;">
                <button type="button" class="layui-btn" lay-submit lay-filter="add" style="width: 100px;float: right;margin-top: 7px;margin: 5px 5px;">保存</button>
                <button type="button" class="layui-btn"  id="cancel"  style="width: 100px;margin-top: 7px;background-color: #b2b2b2;float: right;margin: 5px 5px;" >取消</button>
                <input type="button" style="display: none" id="dataVal" value="">
            </div>
        </form>
    </div>
</div>
<script th:inline="javascript">
    const baseUrl = [[${#servletContext.contextPath}]];
    var flowId = [[${flowId}]];
    var stepId = [[${stepId}]];
    console.log(stepId);

    window.onload = loadFlowStep; //页面载入完毕执行函数
    function loadFlowStep() {
        var speakingFlowStep = [[${speakingFlowStep}]];
        if (speakingFlowStep!=null && speakingFlowStep.skipType!=null) {
            console.log(speakingFlowStep);
            console.log(speakingFlowStep.skipType.value);
            if(speakingFlowStep.skipType == "ASSIGN"){
                $("#assignFlowDiv").css("display", "");
            }else if(speakingFlowStep.skipType == "ASSIGN_STEP"){
                $("#assignFlowStepDiv").css("display", "");
            }
        } else {
            $("#assignFlowDiv").css("display", "none");
            $("#assignFlowStepDiv").css("display", "none");
        }
    }

</script>
<script type="text/javascript"   th:src="@{/js/jquery-1.7.2.min.js}"></script>
<script type="text/javascript"   th:src="@{/js/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/js/layui/layui.all.js}"></script>
<script type="text/javascript"   th:src="@{/js/page/flow/config/saveOrUpdateSpeakingFlowStep.js}"></script>
<script type="text/javascript"   th:src="@{/js/page/utils.js}"></script>
</body>
</html>